<form action="/orders/index/page:1" method="get" class="filter">
    
    <label for="keyword" class="first">Ključna reč:</label>
    <input type="text" name="keyword" id="keyword" value="<?= $keyword ?>" class="large" />
    
    <label for="nezavrseni">Nezavršeni:</label>
    <input type="checkbox" name="nezavrseni" id="nezavrseni" value="1"<? if($nezavrseni): ?> checked="checked"<? endif; ?> />

    <label for="nepreuzeti">Nepreuzeti:</label>
    <input type="checkbox" name="nepreuzeti" id="nepreuzeti" value="1"<? if($nepreuzeti): ?> checked="checked"<? endif; ?> />
    
    <input type="submit" value="Traži" />
</form>
<table class="entity-table clear">
<thead>
    <tr>
        <th width="4%">Broj</th>
        <th width="9%">Datum</th>
        <th width="9%">Popravljeno</th>
        <th width="9%">Preuzeto</th>
        <th width="10%">Mušterija</th>
        <th width="12%">Aparat</th>
        <th>Problem</th>
        <th width="7%"></th>
    </tr>
</thead>
<tbody>
    <? if(! empty($orders)): ?>
        <? foreach ($orders as $k=>$row): ?>
        <?
            $order = $row['Order'];
            $model = $row['BrandModel'];
            $brand = $row['Brand'];
            
            $rowClass = array();
            if (strtotime($order['datum_popravke'])>0) {
                $rowClass[] = 'zavrsen';
            }
            if (strtotime($order['datum_preuzimanja'])>0) {
                $rowClass[] = 'preuzet';
            }
        ?>
        <tr<? if(! empty($rowClass)): ?> class="<?= implode(' ', $rowClass) ?>"<? endif ?> id="<?= $order['id'] ?>">
            <td><?= sprintf("%04d", $order['id']) ?></td>
            <td><?= date_local($order['datum_izdavanja']) ?></td>
            <td><?= date_local($order['datum_popravke']) ?></td>
            <td><?= date_local($order['datum_preuzimanja']) ?></td>
            <td class="mus_tip <?= $order['customer_type_id'] ?>"><?= $order['musterija_ime'] ?></td>
            <td>
                <? if ($brand['name'] && $model['name']): ?>
                    <?= $brand['name'] ? $brand['name'] : 'NEMA' ?> / 
                    <?= $model['name'] ?>
                <? else: ?>
                    NEMA
                <? endif; ?>
            </td>
            <td><?= $order['problem'] ?></td>
            <td class="actions">
                <?= $this->App->action('print', '/orders/aprint/' . $order['id']) ?>
                <?= $this->App->action('delete', '/orders/delete/' . $order['id']) ?>
            </td>
        </tr>
        <? endforeach; ?>
    <? else: ?>
        <tr class="blank">
            <td colspan="7">Nema rezultata</td>
        </tr>
    <? endif; ?>
</tbody>
</table>
<?= $this->element("pagination") ?>

<script type="text/javascript">
$(function(){
    tableRowClick('/orders/edit');
});
</script>